package com.imti.retrofitdemo;

import android.app.Application;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

public class BaseApplication extends Application
{

    public static IWeatherRequest weatherRequest;

    @Override
    public void onCreate()
    {
        super.onCreate();

        Retrofit retrofit =
            new Retrofit.Builder()
                //URL主机地址
                .baseUrl("http://apis.juhe.cn")
                //添加解析插件
                .addConverterFactory(GsonConverterFactory.create())
                //添加RxJava请求框架
                .addCallAdapterFactory(RxJavaCallAdapterFactory.create())
                .build();

        createRequest(retrofit);
    }

    private void createRequest(Retrofit retrofit)
    {
        weatherRequest = retrofit.create(IWeatherRequest.class);
    }
}
